//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.baidu.trace;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import com.baidu.trace.c.a;

public final class u extends SQLiteOpenHelper {
    private SQLiteOpenHelper a = null;
    private Context b = null;

    public final void onCreate(SQLiteDatabase var1) {
        StringBuffer var2;
        (var2 = new StringBuffer("CREATE TABLE if not exists ")).append("trace_location (").append("loc_time INTEGER, ").append("entity_name VARCHAR(128), ").append("location_data BLOB);");
        StringBuffer var3;
        (var3 = new StringBuffer("CREATE TABLE if not exists ")).append("trace_fence (").append("fence_id INTEGER PRIMARY KEY AUTOINCREMENT, ").append("fence_name VARCHAR(128), ").append("monitored_person VARCHAR(128), ").append("coord_type VARCHAR(16), ").append("denoise INTEGER, ").append("fence_shape VARCHAR(16), ").append("create_time VARCHAR(32), ").append("modify_time VARCHAR(32), ").append("monitored_status VARCHAR(16), ").append("fence_extern_info TEXT);");
        StringBuffer var4;
        (var4 = new StringBuffer("CREATE TABLE if not exists ")).append("trace_fence_alarm (").append("fence_id INTEGER, ").append("fence_name VARCHAR(128), ").append("monitored_person VARCHAR(128), ").append("monitored_action VARCHAR(16), ").append("create_time INTEGER, ").append("cur_point TEXT, ").append("pre_point TEXT);");

        try {
            var1.execSQL(var2.toString());
            var1.execSQL(var3.toString());
            var1.execSQL(var4.toString());
        } catch (Exception var5) {
            ;
        }

        if(this.a != null) {
            a.a.execute(new v(this, var1));
        }
    }

    public final void onUpgrade(SQLiteDatabase var1, int var2, int var3) {
        a.a.execute(new w(this, var2, var3, var1));
    }

    public final void onDowngrade(SQLiteDatabase var1, int var2, int var3) {
        super.onDowngrade(var1, var2, var3);
    }

    public u(Context var1) {
        super(var1, "BAIDUTRACE.db", (CursorFactory)null, 3);
        String[] var2 = var1.databaseList();
        if(var2 != null && var2.length != 0) {
            boolean var3 = false;
            int var4 = (var2 = var2).length;

            for(int var5 = 0; var5 < var4; ++var5) {
                String var6 = var2[var5];
                if("BAIDUTRACE.db".equals(var6)) {
                    var1.deleteDatabase("LBSTRACE.db");
                    var3 = false;
                    break;
                }

                if("LBSTRACE.db".equals(var6)) {
                    var3 = true;
                }
            }

            if(var3) {
                this.b = var1;
                this.a = new x(this, var1, "LBSTRACE.db", (CursorFactory)null, 1);
            }

        }
    }

    protected static void a(SQLiteDatabase var0, String var1, String[] var2) {
        try {
            var0.execSQL(var1, var2);
        } catch (Exception var3) {
            ;
        }
    }

    protected static Cursor b(SQLiteDatabase var0, String var1, String[] var2) {
        try {
            return var0.rawQuery(var1, var2);
        } catch (Exception var3) {
            return null;
        }
    }
}
